/**
 * implements Cloneable 克隆第一步
 */
class Person implements Cloneable{
    public int age;
    public String name;

    /**
     * 重写 clone方法克隆第二步
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public String toString() {
        return "["+name+","+age+"]";
    }
}
public class Test2 {
    /**
     * throws CloneNotSupportedException 克隆第三步
     * @param args
     * @throws CloneNotSupportedException
     */
    public static void main(String[] args) throws CloneNotSupportedException{
        Person a = new Person();
        a.name = "123";
        /**
         * (Person)强转 克隆第四步
         */
        Person b = (Person) a.clone();
        b.age = 10;
        System.out.println(b);
    }
}
